package com.kotlin.flong.flow

import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.transform
import kotlinx.coroutines.runBlocking

/**
 * @Author:liangjl
 * @Date: 2020/7/10-21:38
 * @Eamil:jilongliang@sina.com
 * @Description:
 * transform
 */
private suspend fun myExcue(intput: Int): String {
    delay(1000)
    return "input $intput"
}

fun main() = runBlocking {

    (1..10).asFlow().transform { input ->
        emit("my input ")
        emit(myExcue(input))
        emit("hello world")
    }.collect { println(it) }


}